/**
 * Created by vicket on 2017/4/16.
 */
$(function(){

    var searchContent=$(".search_content");
    var searchResult=$(".search_result");
    var searchNovel=$(".search_novell");
    var searchText=$(".search_text");
    var searchTip=$(".search_tip");
    searchContent.css("display","block");
    searchTip.css("display","none");
        searchText.click(function(){
            var searchVal=searchNovel.val();
            if(searchVal.length==0){
                alert("输入内容不能为空");
            }else {
                $.ajax({
                    type: 'get',
                    url: "/api/frontSearchBook",
                    data: {value: searchVal},
                    success: function (result) {
                        if (result[0]) {
                            searchContent.css("display", "none");
                            var html = template("searchResult", {items: result});
                            searchResult.html(html);
                        } else {
                            searchContent.css("display", "block");
                            searchTip.css("display", "block");
                            setTimeout(function () {
                                searchTip.css("display", "none");
                            }, 2000);
                        }
                    }
                })
            }





})})